import { PrismaClient } from '@prisma/client'
import { getQuery } from 'h3'
const prisma = new PrismaClient()

export default defineEventHandler(async (event) => {
    const { userId, postId } = await getQuery(event)
    const post = await prisma.post.findUnique({
        where: {
            id: parseInt(postId),
            userId: parseInt(userId),
        },
        select: {
            id: true,
            score: true,
            content: true,
            speed: true,
            createdAt: true,
            user: {
                select: {
                    nickname: true,
                    phone: true,
                    company: true,
                }
            },
            topic: {
                select: {
                    id: true,
                    title: true,
                    limit: true,
                    quantity: true,
                }
            },
        }
    })
    // 查询考试信息
    return post
})
